package reflect.web.project03;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.util.Map;

public class Solve {
    public static void setParams(Map<String,Object> map) throws InvocationTargetException, IllegalAccessException, InstantiationException {
        Class<Entity> entityClass = Entity.class;
        Method method = entityClass.getMethods()[0];
        Parameter parameter = method.getParameters()[0];
        web.project03.ParamName annotation = parameter.getAnnotation(web.project03.ParamName.class);
        String key = annotation.key();
        Object o = map.get(key);
//        if(o==null){
//            throw Exception();
//        }
        Entity entity = entityClass.newInstance();
        method.invoke(entity,o);
    }
}
